from django.db import models

# Create your models here.
class Department(models.Model):
    """部门表"""
    title = models.CharField(verbose_name='标题', max_length=32)
    def __str__(self):
        return self.title

class UserInfo(models.Model):
    """员工表"""
    name = models.CharField(verbose_name='姓名', max_length=32)
    password = models.CharField(verbose_name='密码', max_length=64)
    age = models.IntegerField(verbose_name='年龄')
    account = models.DecimalField(verbose_name='账户余额', max_digits=10, decimal_places=2, default=0)# 总长10，小数2，默认0
    create_time = models.DateTimeField(verbose_name='入职时间')
    #depart_id =models.BinaryField(verbose_name='部门id', max_length=32)
    depart = models.ForeignKey(verbose_name='部门', to='Department', to_field='id', on_delete=models.CASCADE)
    #约束
    # -to ,与那张表关联
    # -to_field，关联的表中，哪个字段
    #自动加入字段depart_id
    # on_delete=models.CASCADE，级联删除
    # on_delete=models.SET_NULL，置空,null=True,blank=True
    gender = models.SmallIntegerField(verbose_name='性别', choices=((1, '男'), (2, '女')))

class Prettynum(models.Model):
    """靓号表"""
    num = models.CharField(verbose_name='手机号码', max_length=32)
    price = models.IntegerField(verbose_name='价格',null=True,blank=True)
    level_choices = (
        (1, '1级'),
        (2, '2级'),
        (3, '3级'),
        (4, '4级')
    )
    level = models.SmallIntegerField(verbose_name='级别', choices=level_choices, default=1)
    status_choices = (
        (1, '已占用'),
        (2, '未占用')
    )
    status = models.SmallIntegerField(verbose_name='状态', choices=status_choices, default=2)

class Admin(models.Model):
    """管理员表"""
    username = models.CharField(verbose_name='用户名', max_length=32)
    password = models.CharField(verbose_name='密码', max_length=100)
    captcha = models.CharField(verbose_name='验证码', max_length=32)
